package com.tensquare.base.controller;

import common.entity.Result;
import common.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description: 统一异常处理（使用注解完成）
 * @Date: Create in 2019/3/22 16:11
 */
@ControllerAdvice
public class BaseExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        return new Result(false, StatusCode.ERROR,e.getMessage());
    }
}
